﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cylong.Cache
{
    public interface ICacheProvider
    {
        /// <summary>
        /// 更新缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">缓存建</param>
        /// <param name="t">缓存值</param> 
        /// <remarks>更新缓存</remarks>
        /// <returns></returns>
        bool Update<T>(string key, T t);
        T Get<T>(string cacheKey);
        bool Write<T>(string cacheKey, T value);
        bool Write<T>(string key, T t, TimeSpan expireTime);
        bool Remove(string cacheKey);
        /// <summary>
        /// 获取或新增缓存
        /// </summary> 
        /// <param name="key">缓存Key</param> 
        /// <param name="setFunc">缓存</param> 
        /// <author>xiao</author>
        /// <remarks></remarks>
        /// <returns></returns>
        T GetOrAdd<T>(string key, Func<string, T> setFunc) where T : class;



    }
}
